import { FC } from 'react';
import { List } from 'antd';
import { useSelector, useDispatch } from 'umi';

const List2: FC = () => {
  // index表示的模块名
  const list = useSelector((state: any) => state.index.list);
  const dispatch = useDispatch();

  const del = (item: string) => () => {
    dispatch({
      type: 'index/remove',
      payload: item,
    });
  };

  return (
    <List
      size="small"
      bordered
      dataSource={list}
      renderItem={(item: string) => (
        <List.Item onClick={del(item)}>{item}</List.Item>
      )}
    />
  );
};

export default List2;
